<%@ page pageEncoding="utf-8"%> 
<%@page import="java.sql.*"%>
<%@page import="java.util.*"%>

<%
	request.setCharacterEncoding("utf-8");
	request.setAttribute("layout","main.jsp");
	request.setAttribute("page_title","温岭选课系统-课程列表");
	List<Hashtable<String, String>> select_list = (List<Hashtable<String, String>>) session.getAttribute("SelectList");
	Iterator<Hashtable<String, String>> select_it = select_list.iterator();
	double credit = 0;
	double credit2 = 0;
%>
<style>

</style>

<link href="css/jquery.ui.tabs.css" rel="stylesheet">
	<link href="css/jquery.ui.theme.css" rel="stylesheet">
	<link href="css/div_win.css" rel="stylesheet"> 
	<script src="js/div_win.js"></script>
	<script src="js/jquery-1.5.2.min.js"></script>
	<script src="js/jquery-ui-1.8.11.custom.min.js"></script>
	<script src="js/jquery.ui.tabs.js"></script>
	<script type="text/javascript" src="js/popup.js"></script>
	
	<script>
	$(function() {
		$( "#tabs" ).tabs();
	});
	
	function unselect(courseId,name){
	   $.ajax({
			url: base_path+"Student/unselect.do",
			type: "POST",
			data: {"method":"measuring"},
            data: {"courseId":courseId}, 
			beforeSend: function(XMLHttpRequest){
				return confirm("确要退选《"+name+"》吗?");
			},
			success: function(data, textStatus){
				if(data=="success"){
					alert("恭喜您，退选课程成功！");
				}else{ 
					alert("恭喜您，退选课程成功！");
				}
			},

			complete: function(XMLHttpRequest, textStatus){
				window.location.href=base_path+"Student/mySelect.do";
			},
			error: function(){
				alert("服务器异常，请联系网络管理员");
			}
		});
   }
   
	</script>
<div style="width:100%; margin:1px;text-align:center;margin-top:5px;margin-bottom:20px;">
 	
 	<p style="border:0;font-size:14px;padding-bottom:0;text-align:center;">
	</p>
	  <div id="tabs" style="height:700px;width:90%;margin-left:5%;">
		<ul>
			<li><a href="#tabs-1">我的选课</a></li>
			<li><a href="#tabs-2">历史选课</a></li>
		</ul>
<div id="tabs-1" style="width:100%;margin-left:0;padding-left:0;margin-top:20px;">
<style>
	tr{
		height:30px;
	}
	.tdLeft{
		align:left;
		text-align:left;
		padding-left:20px;
		
	}
</style>
  <p style="border:0;font-size:14px;padding-bottom:0;">
  </p>
  <table   style="border:1px solid gray;margin-left:1%;width:98%;">
    <tbody>
              <tr height="32" bgcolor="#f0f0f0">
                    <td align="center" width="7%">课程编号</td>
                    <td align="center" width="8%">开课学期</td>
                    <td align="center" width="8%">课程类型</td>
                    <td align="center" width="8%">课程名称</td>
                    <td align="center" width="6%">授课老师</td>
                    <td align="center" width="13%">上课时间|地点</td>
                    <td align="center" width="5%">学分</td>
                    <td align="center" width="8%">人数限额<br>
                      (最多/最少)</td>
                    <td align="center" width="6%">已选人数</td>
                    <td align="center" width="7%">课程状态</td>
                    <td align="center" width="7%">选课状态</td>
                    <td align="center" width="15%">操作</td>
             </tr>
             <%
              		select_it = select_list.iterator();
		        	while(select_it.hasNext())
					{
						Hashtable<String, String> cousrelist_hash  = select_it.next();
						credit += Double.parseDouble(cousrelist_hash.get("credit"));
			 %>
			  	<tr height="25" bgcolor="#ffffff">
		            <td align="center"><%=cousrelist_hash.get("classno") %></td>
		            <td align="center"><%=cousrelist_hash.get("year") %><%=cousrelist_hash.get("openterm") %></td>
		            <td align="center"><%=cousrelist_hash.get("type") %></td>
		            <td align="center"><%=cousrelist_hash.get("name") %> </td>
		            <td align="center"><%=cousrelist_hash.get("teachers") %> </td>
		            <td align="center"><%=cousrelist_hash.get("teach_time") %> | <%=cousrelist_hash.get("teach_location") %> </td>
		            <td align="center"><%=cousrelist_hash.get("credit") %> </td>
		            <td align="center"><%=cousrelist_hash.get("students_low") %>/<%=cousrelist_hash.get("students_high") %> </td>
		            <td align="center"><%=cousrelist_hash.get("num_of_students") %> </td>
		            <td align="center">
		            <% if(cousrelist_hash.get("checkstatus").equalsIgnoreCase("0")){%>
			             		审核中
				             	<% }else if(cousrelist_hash.get("checkstatus").equalsIgnoreCase("1")){ %>
				             		审核通过
				             	<%}else if(cousrelist_hash.get("checkstatus").equalsIgnoreCase("2")){ %>
				             		审核不通过
				             	<%}else if(cousrelist_hash.get("checkstatus").equalsIgnoreCase("3")){ %>
				             		选课中
				             	<%}else if(cousrelist_hash.get("checkstatus").equalsIgnoreCase("4")){ %>
				             		开课
				             	<%}else if(cousrelist_hash.get("checkstatus").equalsIgnoreCase("5")){ %>
				             		结束
				    <%} %>
		            </td>
		            <td align="center">
		            <% if(cousrelist_hash.get("status").equalsIgnoreCase("0")){%>
			             		审核中
				    <% }else if(cousrelist_hash.get("status").equalsIgnoreCase("1")){ %>
				             		审核通过
				    <%}else if(cousrelist_hash.get("status").equalsIgnoreCase("2")){ %>
				             		审核不通过
				    <%} %>
		            </td>
		            <td align="center">
		            	<% if(cousrelist_hash.get("status").equalsIgnoreCase("0")){%>
		                 <a href="javascript:unselect('<%=cousrelist_hash.get("Id")%>','<%=cousrelist_hash.get("name") %>')"   class="approve">退选</a>&nbsp;|&nbsp;
		                 <%} %>
			          	 <a href="Admin/detail.do?courseId=<%=cousrelist_hash.get("Id")%>"  class="approve" >查看</a>&nbsp;|&nbsp;成绩
		            </td>
		         </tr>
			  <%} %>
      </tbody>
    </table>
    <p style="border:0;font-size:12px;padding-bottom:0;padding-right:20px;padding-top:20px;text-align:right;">
  		<b>总修学分数：<%=credit %></b>
	</p>
</div>
<div id="tabs-2" style="width:100%;margin-left:0;padding-left:0;margin-top:20px;">
  <p style="border:0;font-size:14px;padding-bottom:0;">
  </p>
  <div style="width:100%; margin:1px;text-align:center;margin-top:10px;margin-bottom:50px;">
  <table   style="border:1px solid gray;margin-left:1%;width:98%;">
    <tbody>
              <tr height="32" bgcolor="#f0f0f0">
                    <td align="center" width="7%">课程编号</td>
                    <td align="center" width="8%">课程类型</td>
                    <td align="center" width="14%">课程名称</td>
                    <td align="center" width="7%">授课老师</td>
                    <td align="center" width="13%">上课时间|地点</td>
                    <td align="center" width="6%">学分</td>
                    <td align="center" width="10%">人数限额<br>
                      (最多/最少)</td>
                    <td align="center" width="6%">已选人数</td>
                    <td align="center" width="7%">课程状态</td>
                    <td align="center" width="7%">选课状态</td>
                    <td align="center" width="15%">操作</td>
             </tr>
             <%
              		select_it = select_list.iterator();
		        	while(select_it.hasNext())
					{
						Hashtable<String, String> cousrelist_hash  = select_it.next();
						credit2 += Double.parseDouble(cousrelist_hash.get("credit"));
			 %>
			  	<tr height="25" bgcolor="#ffffff">
		            <td align="center"><%=cousrelist_hash.get("classno") %></td>
		            <td align="center"><%=cousrelist_hash.get("type") %></td>
		            <td align="center"><%=cousrelist_hash.get("name") %> </td>
		            <td align="center"><%=cousrelist_hash.get("teachers") %> </td>
		            <td align="center"><%=cousrelist_hash.get("teach_time") %> | <%=cousrelist_hash.get("teach_location") %> </td>
		            <td align="center"><%=cousrelist_hash.get("credit") %> </td>
		            <td align="center"><%=cousrelist_hash.get("students_low") %>/<%=cousrelist_hash.get("students_high") %> </td>
		            <td align="center"><%=cousrelist_hash.get("num_of_students") %> </td>
		            <td align="center">
		            <% if(cousrelist_hash.get("checkstatus").equalsIgnoreCase("0")){%>
			             		审核中
				             	<% }else if(cousrelist_hash.get("checkstatus").equalsIgnoreCase("1")){ %>
				             		审核通过
				             	<%}else if(cousrelist_hash.get("checkstatus").equalsIgnoreCase("2")){ %>
				             		审核不通过
				             	<%}else if(cousrelist_hash.get("checkstatus").equalsIgnoreCase("3")){ %>
				             		选课中
				             	<%}else if(cousrelist_hash.get("checkstatus").equalsIgnoreCase("4")){ %>
				             		开课
				             	<%}else if(cousrelist_hash.get("checkstatus").equalsIgnoreCase("5")){ %>
				             		结束
				    <%} %>
		            </td>
		            <td align="center">
		            <% if(cousrelist_hash.get("status").equalsIgnoreCase("0")){%>
			             		审核中
				    <% }else if(cousrelist_hash.get("status").equalsIgnoreCase("1")){ %>
				             		审核通过
				    <%}else if(cousrelist_hash.get("status").equalsIgnoreCase("2")){ %>
				             		审核不通过
				    <%} %>
		            </td>
		            <td align="center">
			          	 <a href="Admin/detail.do?courseId=<%=cousrelist_hash.get("Id")%>"  class="approve" >查看</a>&nbsp;|&nbsp;成绩
		            </td>
		         </tr>
			  <%} %>
      </tbody>
    </table>
    <p style="border:0;font-size:12px;padding-bottom:0;padding-right:20px;padding-top:20px;text-align:right;">
  		<b>总修学分数：<%=credit2 %></b>
	</p>
	</div>
  </div>
 </div>
</div>
